//
//  GlobalMethod+Data.h
//  MexicoLoan
//
//  Created by wxp on 2025/2/26.
//

#import "GlobalMethod.h"

NS_ASSUME_NONNULL_BEGIN

@interface GlobalMethod (Data)

// 清空本地数据
+ (void)clearUserDefault;

#pragma mark - 读写本地数据
// 有前缀
+ (void)writeStr:(NSString *)strValue forKey:(NSString *)strKey;
+ (NSString *)readStrFromUserDefaults:(NSString *)strKey;
// 无前缀
+ (void)writeUnprefixStr:(NSString *)strValue forKey:(NSString *)strKey;
+ (NSString *)readUnprefixStrFromUserDefaults:(NSString *)strKey;
// bool
+ (void)writeBool:(BOOL)bol local:(NSString *)strKey;
+ (BOOL)readBoolLocal:(NSString *)strKey;

#pragma mark - 数据类型转换
// 转换String to dic
+ (NSDictionary *)exchangeStringToDic:(NSString *)str;
// 转换String to ary
+ (NSArray *)exchangeStringToAry:(NSString *)str;
// 转换data to dic
+ (NSDictionary *)exchangeDataToDic:(NSData *)data;
// 转换 dic to model
+ (id)exchangeDicToModel:(id)dic modelName:(NSString *)strName;
// 转换dic to ary
+ (NSMutableArray *)exchangeDic:(id)response toAryWithModelName:(NSString *)modelName;
+ (NSMutableArray *)exchangeAryModelToAryDic:(NSArray *)response;
// 转换json
+ (NSString *)exchangeDicToJson:(id)object;
+ (NSString *)exchangeModelsToJson:(NSArray *)object;
+ (NSString *)exchangeModelToJson:(id)model;


#pragma mark - 日期时间
// date 转 时间戳
+ (NSString *)changeDateToStr:(NSDate *)date;
// date 转 (formate格式) - NSString
+ (NSString *)exchangeDate:(NSDate *)date formatter:(NSString *)formate;
// NSString 转 (formate格式) - NSDate
+ (NSDate *)exchangeString:(NSString *)str formatter:(NSString *)formate;
// 时间戳 转 格式时间
+ (NSString *)exchangeTimestamp:(NSString *)timestampString formate:(NSString *)formate;

#pragma mark - double数据显示
+ (NSString *)formattedDouble:(double)number;

@end

NS_ASSUME_NONNULL_END
